import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({

    history: createWebHistory(),
    routes: [
        {
            //Vue3需要使用正则的形式配置指定未识别的路径 :pathMatch(.*)*
            path: '/',
            redirect: '/findMusic/recommend',
        },
        // 发现音乐
        {
            path: '/findMusic',
            component: () => import("../views/Discovery/index.vue"),
            name: 'findMusic',
            redirect: '/findMusic/recommend',
            children: [
                {
                    path: 'recommend',
                    component: () => import("../views/Discovery/Recommend.vue"),
                    name: 'recommend'
                },
                {
                    path: 'songList',
                    component: () => import("../views/Discovery/PlayList.vue"),
                    name: 'songList'
                }
            ]
        },
        // 歌单详情页
        {
            path: '/playlistDetails/:id',
            component: () => import('../views/PlaylistDetails/index.vue'),
            name: 'playlistDetails',
            // 参数携带id
            props(route) {
                return {
                    id: route.params.id,
                }
            },
        },
        // 歌手详情页
        {
            path: '/singerDetails',
            component: () => import('../views/SingerDetails/index.vue'),
            name: 'singerDetails',
        },

        // 搜索详情页
        {
            path: '/search/songs',
            component: () => import('../views/searchDetails/index.vue'),
            children:[
                // 歌曲
                {
                    path:':keywords',
                    component:()=>import('../views/searchDetails/Songs.vue'),
                    name:'searchSongs',
                    props(route){
                        return {
                            keywords: route.params.keywords,
                        }
                    }
                }
            ]
        }
    ]
})

export default router